package com.github.lfg.study.java.jvm.app;

import c_6_1_4.FullCPUTask;
import c_6_1_4.FullIOTask;
import c_6_1_4.LazyTask;
import c_6_3_6.DeadLock;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class StudySpringAppApplication {

    public static void main(String[] args) {
        SpringApplication.run(StudySpringAppApplication.class, args);

        //cpu高占用线程
//        FullCPUTask();

        //IO高占用线程
//        FullIOTask();

        //死锁
//        DealLockTask();


    }

    private static void FullCPUTask() {
        //cpu高占用线程
        new Thread(new FullCPUTask()).start();

        //空闲线程
        new Thread(new LazyTask()).start();
        new Thread(new LazyTask()).start();
        new Thread(new LazyTask()).start();
    }

    private static void FullIOTask() {
        //IO高占用线程
        new Thread(new FullIOTask()).start();

        //空闲线程
        new Thread(new LazyTask()).start();
        new Thread(new LazyTask()).start();
        new Thread(new LazyTask()).start();
    }

    private static void DealLockTask() {

        //狗狗，先持有猫咪的锁，再去获取狗狗的锁
        new DeadLock.DogThread().start();

        //猫咪，先持有狗狗的锁，再去获取猫咪的锁
        new DeadLock.CatThread().start();

        //空闲线程
        new Thread(new LazyTask()).start();
        new Thread(new LazyTask()).start();
        new Thread(new LazyTask()).start();
    }

}
